﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtendModule;

namespace LabMS.Web.Equipment.Valuables
{
    public partial class valuablesborrowlist : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("GZSBLY");//必须写在ispostback外
            strPageUserType.Add("mana");
            if (!IsPostBack)
            {
                Bind("");
            }
        }

        public void Bind(string strWhere)
        {
            List<ExtendModule.Recipients> listevaluables = new List<Recipients>();
            ExtendBLL.Recipients bevaluables = new ExtendBLL.Recipients();
            listevaluables = bevaluables.GetExtendModelList(" Recipients.Type='guizhongyiqi' And Recipients.ReturnTime is null " + strWhere + " order by Recipients.ID desc ");
            GridViewValuables.DataSource = listevaluables;
            GridViewValuables.DataBind();
        }

        protected void GridViewValuables_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
                //e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");
                e.Row.Attributes["style"] = "Cursor:pointer";
                int itemp = e.Row.Cells.Count;
                for (int i = 1; i < itemp; i++)
                {
                    e.Row.Cells[i].Attributes.Add("OnDblClick", "window.location.href='valuablesreturn.aspx?ID=" + GridViewValuables.DataKeys[GridViewValuables.DataKeys.Count - 1].Value.ToString() + "'");
                }
            }
        }

        protected void lbRefresh_Click(object sender, EventArgs e)
        {
            Bind("");
        }

        protected void lbSearch_Click(object sender, EventArgs e)
        {
            string strWhere = " and Name like '%" + tbKeyword.Text.Trim() + "%' ";
            Bind(strWhere);
        }

        protected void GridViewValuables_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridViewValuables.PageIndex = e.NewPageIndex;
            if (tbKeyword.Text.Trim().Equals(""))
            {
                Bind("");
            }
            else
            {
                string strWhere = " and Name like '%" + tbKeyword.Text.Trim() + "%' ";
                Bind(strWhere);
            }
        }
    }
}
